﻿#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.dll"
#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.Runtime.dll"
#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.DocumentManagement.dll"
#r @"..\Microsoft.SharePoint.Client (spo)\Microsoft.SharePoint.Client.Taxonomy.dll"

#load "Client.fs"

open Client
open Microsoft.SharePoint.Client
open Microsoft.SharePoint.Client.Application
open Microsoft.SharePoint.Client.Taxonomy
open Microsoft.SharePoint.Client.WebParts
open Microsoft.SharePoint.Client.DocumentManagement
open Microsoft.SharePoint.Client.DocumentSet
open System.Security
open System
open System.Xml
    
// =======================================================
// Work with the recycle bin
// =======================================================

let site = Client.Context.Site
let recycleItems = site.RecycleBin
Client.Load recycleItems

recycleItems.Count

for item in recycleItems do
    Client.Load item
    let props = item.IsPropertyAvailable("ContentTypeId")
    let msg = props.ToString() + "|" + item.Id.ToString()
    printfn "%s\n" msg

let item = recycleItems.GetById(Guid.Parse("6490c0de-8315-42ab-8b96-a7a8276d4847"))
Client.Load item

item.Retrieve("ContentTypeId")
item.TypedObject